<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
    <style>
        div {
            width: 700px;
            height: 500px;
        }
    </style>
        <div>
            <img src="https://gitee.com/eat-it-if-you-cant-recite-it/gallery/raw/master/img/19ffa7c5553fa8b89c803ed7f069880-2022-11-1723:01:20.jpg" style="width: 1400px; height:800px">
        </div>
        <script>
            //HTMLCollection数组
            var img = document.getElementsByTagName('img')[0];
            const imgArr =['https://gitee.com/eat-it-if-you-cant-recite-it/gallery/raw/master/img/19ffa7c5553fa8b89c803ed7f069880-2022-11-1723:01:20.jpg','https://gitee.com/eat-it-if-you-cant-recite-it/gallery/raw/master/img/8125fbe798d1e4ce53c08ddd2c654b0-2022-11-1723:04:52.jpg','https://gitee.com/eat-it-if-you-cant-recite-it/gallery/raw/master/img/20b493868ceb24ee8f278884dd2c87b-2022-11-1723:03:37.jpg']
            
            var count = 0;
    
            //只执行一次
            function fn() {
                if(count<2){
                    count++;
                }else{
                    count = 0;
                }
                
                img.src = imgArr[count];
                //n! 递归(调用函数本身): 出口， 表达式
                return setTimeout(fn, 3000);
            }
            setTimeout(fn, 3000);
        </script>
    
</head>
<body>
    
</body>
</html>